using UnityEngine;

public class ClickListener : MonoBehaviour
{
	public ButtonID id;

	public bool isDisalbeSound;

	public UIButton btn;

	private void Awake()
	{
		btn = GetComponent<UIButton>();
		if (btn != null)
		{
			btn.pressed = new Color(1f, 1f, 1f, 0.5f);
		}
	}

	private void OnClick()
	{
		switch (UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex)
		{
		case 1:
			Instance<UIMain>.instance.handleClick(id);
			break;
		case 2:
			Instance<UIChooseTeam>.instance.handleClick(id);
			break;
		case 3:
			Instance<UIChooseClothe>.instance.handleClick(id);
			break;
		case 8:
			Instance<UIChooseLevel>.instance.handleClick(id);
			break;
		case 5:
			Instance<UIChooseMode>.instance.handleClick(id);
			break;
		case 6:
			Instance<UITeamManage>.instance.handleClick(id);
			break;
		case 7:
			Instance<UIShop>.instance.handleClick(id);
			break;
		case 4:
			if (id != ButtonID.BTN_UIGAME_SHOOT)
			{
				Instance<UIGame>.instance.handleClick(id);
			}
			break;
		}
		if (!isDisalbeSound)
		{
			Instance<AudioController>.instance.play(AudioType.Sound_button);
		}
	}

	private void OnPress(bool isPressed)
	{
		if (id == ButtonID.BTN_UIGAME_SHOOT && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex == 4)
		{
			Instance<UIGame>.instance.isPressingShoot = isPressed;
			if (isPressed)
			{
				Instance<UIGame>.instance.handleClick(id);
			}
		}
	}
}
